﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace GPSTrackingWebsiteManager.Manager.UserControls
{
    public partial class DepartmentSearch : System.Web.UI.UserControl
    {
        //Events
        public delegate void AcceptEvent(List<GridDataItem> rows);
        public event AcceptEvent OnAcceptEvent;

        //Propeties
        [Browsable(true), Category("Custom"), DefaultValue(true)]

        public void clearDepartmentGrid()
        {
            DepartmentGrid.DataSource = new string[] { };
            DepartmentGrid.DataBind();
        }

        protected void GetDepartmentGridToAssociate()
        {
            DepartmentGrid.DataSource = GPSTrackingDBV2.Data.DataRepository.DepartmentsProvider.GetAll();//(txtSearchImei.Text, txtSearchName.Text, txtSearchSimNumber.Text, txtSearchDescription.Text, gpsTypeID, gpsModelID);
            DepartmentGrid.DataBind();
        }

        protected void btnDepartmentOK_Click(object sender, EventArgs e)
        {
            List<GridDataItem> rows = new List<GridDataItem>();
            foreach (Telerik.Web.UI.GridDataItem selectedItem in DepartmentGrid.SelectedItems)
            {
                rows.Add(selectedItem);
            }
            clearDepartmentGrid();
            OnAcceptEvent(rows);
        }
    }
}